var textarea = document.querySelector(".reply-text");
var replyBtn = document.querySelector(".reply-btn.disable");
textarea.addEventListener("input", function (e) {
  if (textarea.value == "") {
    replyBtn.setAttribute("disabled", true);
    replyBtn.classList.add("disable");
  } else {
    replyBtn.removeAttribute("disabled");
    replyBtn.classList.remove("disable");
  }
  this.style.height = "inherit";
  this.style.height = `${this.scrollHeight}px`;
});

var cancel = document.querySelector(".top-cancel");
var mask = document.querySelector(".mask");
cancel.onclick = function () {
  mask.style.display = "none";
  document.body.style.overflow = "inherit";
};
var reply = document.getElementsByClassName("reply");

for (let i = 0; i < reply.length; i++) {
  reply[i].onclick = function () {
    document.body.style.overflow = "hidden";
    mask.style.display = "flex";
  };
}
textarea.onkeyup = function () {
  let ddl = document.querySelector(".ddl");
  let str = textarea.value;
  console.log(textarea.value.length);
  ddl.innerHTML = `还可输入${100 - textarea.value.length}字`;
  if (textarea.value.length >= 100) {
    ddl.innerHTML = "还可输入0字";
    textarea.value = textarea.value.substr(0, 100);
  }
};
